package com.diandian.backend.dingding.data.controller;

import com.diandian.backend.dingding.data.service.DingdingDeptTreeSyncService;
import com.diandian.base.boot.starter.response.BaseResult;
import com.diandian.base.boot.starter.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * [钉钉]部门树表
 */
@RestController
@RequestMapping("/dept/tree")
public class DingdingDeptTreeSyncController {

    @Autowired
    private DingdingDeptTreeSyncService dingdingDeptTreeSyncService;

    /**
     * 同步完整组织
     */
    @GetMapping("/pull")
    public BaseResult pullDeptTree(@RequestHeader(value = "appKey") String appKey,
                                   @RequestHeader(value = "appSecret") String appSecret,
                                   @RequestHeader(value = "belong") String belong) {
        String rootDeptName = "婴贝儿科技有限公司";
        dingdingDeptTreeSyncService.pull(belong, appKey, appSecret, rootDeptName);
        return ResultUtil.makeResult();
    }
}